<?php
if(!defined('IN_IBEIKE')) {
	exit('Access Denied');
}

class table_city_feel extends common_table
{
	public function __construct() {

		$this->_table = 'city_feel';
		$this->_pk    = 'tid';

		parent::__construct();
	}
	public function fetch_all_by_tid($tid){
		if(!empty($tid)&&$tid){
			return DB::fetch_all('SELECT * FROM %t WHERE tid=%s',array($this->_table,$tid));//返回数组包含各个字段的值
		}
		return false;
	}
	
	public function add_feel($data, $return_insert_id = false){
		if($data && is_array($data)){
			return DB::insert($this->_table, $data, $return_insert_id = false);
		}
		return 0;
	}
	public function count_by_tid($tid) {
		return $tid ? DB::result_first('SELECT COUNT(*) FROM %t WHERE tid=%d', array($this->_table, $tid)) : 0;
	}
	public function delete_by_tid($tid) {
		return dintval($tid, true) ? DB::delete($this->_table, DB::field('tid', $tid)) : 0;
	}
	public function update_by_tid($tid, $data) {
		if(($tid = dintval($tid)) && !empty($data) && is_array($data)) {
			return DB::update($this->_table, $data, array('tid' => $tid));
		}
		return 0;
	}
	//not sure about pageorder.
	/*public function fetch_by_aid_page($aid, $page = 1) {
		if(($page = dintval($page))<1) $page = 1;
		return $aid ? DB::fetch_first('SELECT * FROM %t WHERE aid=%d ORDER BY pageorder'.DB::LIMIT($page-1, 1), array($this->_table, $aid)) : false;
	}*/
	public function fetch_all($tid) {
		return $tid ? DB::fetch_all('SELECT * FROM %t WHERE tid=%d ORDER BY pageorder', array($this->_table, $tid)) : array();
	}
	
	
	
}

?>
